<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$lotto_id = intval($_GET['id']);
$conf = new Config();
$stopbet = $conf->get("waitbet");
if (!isset($_SESSION['saywaitmod']))
{
    $_SESSION['saywaitmod'] = 0;
}
$saystopmod = $_SESSION['saywaitmod'];
if ($stopbet <= date("Hi") && !$saystopmod)
{
    $saystopmod = 1;
    $_SESSION['saywaitmod'] = $saystopmod;
    echo "-1";
    exit();
}
$disk_code = "a";
$diskStr = "";
$split = 1;
$ratemod = 2;
include( "class_6h/BetTotal_6h.php" );
$BetTotal_6h = new BetTotal_6h($lotto_id);
$dataTotalArr = array();
$showDataArr = array();
$total_win = array();
$theacl = $curruser['acl'];
$userid = $curruser['id'];
$showid = $theacl == 255 ? "0" : $userid;
$betids = array(15, 16, 17, 23);
$bettypeStr = "15,16,17,23";
foreach ($betids as $betid)
{
    switch ($betid)
    {
        case 15 :
            $jStart = "1";
            $jEnd = "3";
            break;
        case 16 :
            $jStart = "3";
            $jEnd = "5";
            break;
        case 17 :
            $jStart = "5";
            $jEnd = "8";
            break;
        case 23 :
            $jStart = "8";
            $jEnd = "10";
            break;
    }
    $i = 1;
    while ($i < 7)
    {
        $j = $jStart;
        while ($j < $jEnd)
        {
            $showDataArr["{$betid}_{$i}"]["{$i} {$j}"] = array("numbers" => "{$i} {$j}", "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "rate" => 0, "back1" => 0, "back2" => 0, "winlost" => 0, "namount" => "");
            ++$j;
        }
        $dataTotalArr["{$betid}_{$i}"] = array("bettype" => "{$betid}_{$i}", "totalnum" => 0, "amount" => 0, "amount_rate" => 0, "back1" => 0, "back2" => 0);
        $total_win["{$betid}_{$i}"] = 0;
        ++$i;
    }
}
$sql = $BetTotal_6h->getDataListByNumSsSQL($lotto_id, $bettypeStr, $showid, $diskStr, $split, $ratemod);
$rs = getdb($sql);
$updatetime = systime() - 30;
while (!$rs->eof)
{
    $bettype = $rs->f['bettype'];
    $winlost = 0;
    $i = $rs->f['numbers'];
    $tempNumber = substr($i, 0, 1);
    $bettype = "{$bettype}_{$tempNumber}";
    $dataTotalArr[$bettype] += "totalnum";
    $dataTotalArr[$bettype] += "amount";
    $dataTotalArr[$bettype] += "back1";
    $dataTotalArr[$bettype] += "back2";
    $total_win[$bettype] = $dataTotalArr[$bettype]['amount'] - $dataTotalArr[$bettype]['back1'] + $dataTotalArr[$bettype]['back2'];
    $showDataArr[$bettype][$i]['totalnum'] = $rs->f['totalnum'];
    $showDataArr[$bettype][$i]['amount'] = $rs->f['amount'];
    $showDataArr[$bettype][$i]['amount_rate'] = $rs->f['amount_rate'];
    $showDataArr[$bettype][$i]['rate'] = $rs->f['rate'];
    $rs->next();
}
$rs->close();
$rs = getdb("select * from rate15a where lotto_id={$lotto_id}");
if ($rs->eof)
{
    exit("Error ID!");
}
$i = 1;
while ($i < 7)
{
    $showDataArr["15_{$i}"]["{$i} 1"]['rate'] = $rs->f["r15_{$i}_1"] - 0;
    $showDataArr["15_{$i}"]["{$i} 2"]['rate'] = $rs->f["r15_{$i}_2"] - 0;
    $showDataArr["16_{$i}"]["{$i} 3"]['rate'] = $rs->f["r15_{$i}_3"] - 0;
    $showDataArr["16_{$i}"]["{$i} 4"]['rate'] = $rs->f["r15_{$i}_4"] - 0;
    $showDataArr["17_{$i}"]["{$i} 5"]['rate'] = $rs->f["r15_{$i}_5"] - 0;
    $showDataArr["17_{$i}"]["{$i} 6"]['rate'] = $rs->f["r15_{$i}_6"] - 0;
    $showDataArr["17_{$i}"]["{$i} 7"]['rate'] = $rs->f["r15_{$i}_7"] - 0;
    $showDataArr["23_{$i}"]["{$i} 8"]['rate'] = $rs->f["r15_{$i}_8"] - 0;
    $showDataArr["23_{$i}"]["{$i} 9"]['rate'] = $rs->f["r15_{$i}_9"] - 0;
    ++$i;
}
$rs->close();
$i = 1;
while ($i < 7)
{
    $tempIdx = "15_{$i}";
    echo $total_win[$tempIdx];
    echo "," . $showDataArr[$tempIdx]["{$i} 1"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 1"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 1"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 1"]['amount_rate'];
    echo "," . $showDataArr[$tempIdx]["{$i} 2"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 2"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 2"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 2"]['amount_rate'];
    echo "\n";
    $tempIdx = "16_{$i}";
    echo $total_win[$tempIdx];
    echo "," . $showDataArr[$tempIdx]["{$i} 3"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 3"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 3"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 3"]['amount_rate'];
    echo "," . $showDataArr[$tempIdx]["{$i} 4"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 4"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 4"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 4"]['amount_rate'];
    echo "\n";
    $tempIdx = "17_{$i}";
    echo $total_win[$tempIdx];
    echo "," . $showDataArr[$tempIdx]["{$i} 5"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 5"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 5"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 5"]['amount_rate'];
    echo "," . $showDataArr[$tempIdx]["{$i} 6"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 6"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 6"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 6"]['amount_rate'];
    echo "," . $showDataArr[$tempIdx]["{$i} 7"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 7"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 7"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 7"]['amount_rate'];
    echo "\n";
    $tempIdx = "23_{$i}";
    echo $total_win[$tempIdx];
    echo "," . $showDataArr[$tempIdx]["{$i} 8"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 8"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 8"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 8"]['amount_rate'];
    echo "," . $showDataArr[$tempIdx]["{$i} 9"]['rate'] . "@" . $showDataArr[$tempIdx]["{$i} 9"]['totalnum'] . "@" . $showDataArr[$tempIdx]["{$i} 9"]['amount'];
    echo "@" . $showDataArr[$tempIdx]["{$i} 9"]['amount_rate'];
    echo "\n";
    ++$i;
}
include( "class_6h/class.menu.php" );
$fieldArr = array("lotto_id" => $lotto_id, "split_id" => 1);
$onlineMenu = new menu_6h(2, $fieldArr);
echo $onlineMenu->getMenuAmu();
echo "\n";
exit();
?>